package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppUserTeamMemberMapper;
import com.letoken.platform.repo.app.po.AppUserTeamMember;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wyl
 * @date 2022/12/27 18:36
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppUserTeamMemberManager {

    @Resource
    private AppUserTeamMemberMapper appUserTeamMemberMapper;

    /**
     * 根据用户id和团员id查询唯一的团队信息
     * @param userId
     * @return
     */
    public AppUserTeamMember queryTeamMemberByUserId(Integer userId) {
        LambdaQueryWrapper<AppUserTeamMember> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppUserTeamMember::getUserId, userId).eq(AppUserTeamMember::getMemberId, userId);
        AppUserTeamMember appUserTeamMember = appUserTeamMemberMapper.selectOne(queryWrapper);
        return appUserTeamMember;
    }

    /**
     * 根据用户id查询的团队列表
     * @param userId
     * @return
     */
    public List<AppUserTeamMember> queryTeamMemberListByUserId(Integer userId) {
        LambdaQueryWrapper<AppUserTeamMember> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppUserTeamMember::getUserId, userId);
        return  appUserTeamMemberMapper.selectList(queryWrapper);
    }

    /**
     * 根据和团员id查询唯一的团队信息
     * @param memberId
     * @return
     */
    public AppUserTeamMember queryTeamMemberByMemberId(Integer memberId) {
        LambdaQueryWrapper<AppUserTeamMember> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppUserTeamMember::getMemberId, memberId);
        AppUserTeamMember appUserTeamMember = appUserTeamMemberMapper.selectOne(queryWrapper);
        return appUserTeamMember;
    }

}
